#include "wprogressbar.h"
#include "ui_wprogressbar.h"

WProgressBar *WProgressBar::instance = NULL;

WProgressBar::WProgressBar(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::WProgressBar)
{
    ui->setupUi(this);
    step = 0;
}

WProgressBar * WProgressBar::getInstance(QWidget *parent)
{
    if(instance == NULL)
    {
        instance = new WProgressBar(parent);
    }
    return instance;
}

WProgressBar::~WProgressBar()
{
    delete ui;
}

void WProgressBar::setMaximumStep(const int step)
{
    maxStep = step;
    ui->progressBar->setMaximum(step);
}

void WProgressBar::progress()
{
    ui->progressBar->setValue(++step);
}

void WProgressBar::stop()
{
    step = 0;
    ui->progressBar->setValue(step);
    ui->progressBar->reset();
}

void WProgressBar::setText(const QString &text)
{
    ui->label->setVisible(true);
    ui->label->setText(text);
}

void WProgressBar::hideText(const bool hide)
{
    ui->label->setVisible(hide);
}
